import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PurchaseContractVO, PurchaseContractForm, PurchaseContractQuery } from '@/api/finance/purchaseContract/types';

/**
 * 查询采购合同列表
 * @param query
 * @returns {*}
 */

export const listPurchaseContract = (query?: PurchaseContractQuery): AxiosPromise<PurchaseContractVO[]> => {
  return request({
    url: '/finance/purchaseContract/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询采购合同详细
 * @param id
 */
export const getPurchaseContract = (id: string | number): AxiosPromise<PurchaseContractVO> => {
  return request({
    url: '/finance/purchaseContract/' + id,
    method: 'get'
  });
};

/**
 * 新增采购合同
 * @param data
 */
export const addPurchaseContract = (data: PurchaseContractForm) => {
  return request({
    url: '/finance/purchaseContract',
    method: 'post',
    data: data
  });
};

/**
 * 修改采购合同
 * @param data
 */
export const updatePurchaseContract = (data: PurchaseContractForm) => {
  return request({
    url: '/finance/purchaseContract',
    method: 'put',
    data: data
  });
};

/**
 * 删除采购合同
 * @param id
 */
export const delPurchaseContract = (id: string | number | Array<string | number>) => {
  return request({
    url: '/finance/purchaseContract/' + id,
    method: 'delete'
  });
};
